# !usr/bin/env python
# -*-coding:utf-8 -*-

# @FileName: receive_.py
# @Author:tian
# @Time:06/19/2021

import pika,sys,time

connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
channel = connection.channel()

def callback(ch, method, properties, body):
    print(f'{time.time()} receive {body}')
    ch.basic_ack(delivery_tag=method.delivery_tag)

channel.basic_consume(queue='balance',on_message_callback=callback,auto_ack=False)
print('[*] Waiting for messages. To exit press CTRL+C')

try:
    channel.start_consuming()
except KeyboardInterrupt:
    sys.exit(0)

